﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Schema;

namespace 贪吃蛇
{
     abstract class BeginorEndBaseScene  : ISceneUpdate
    {
        protected int nowSelIndex = 0; //判断当前所选择的是哪个选项
        protected string strTitle;    //变化的东西用变量去申明它
        protected string strOne;
        public abstract void EnterJDoSomething();
        public void UpDate()
        {
           //开始和结束场景的 游戏逻辑
           //选择当前的选项 然后 监听 键盘那输入 wsj
           Console.ForegroundColor = ConsoleColor.White;
            //显示标题
        Console.SetCursorPosition(40 - strTitle.Length , 5);
        Console.WriteLine(strTitle);
        Console.SetCursorPosition(40 - strOne.Length, 8);
        Console.ForegroundColor = nowSelIndex ==  0 ? ConsoleColor.Red : ConsoleColor.White; //显示下方的选项 根据当前的索引选择颜色 
        Console.WriteLine(strOne);
        Console.SetCursorPosition(40 - 4, 11);
          
            Console.ForegroundColor = nowSelIndex == 1? ConsoleColor.Red : ConsoleColor.White;
            Console.WriteLine("结束游戏");
            //检测输入
            switch (Console.ReadKey(true).Key)
            {
                case ConsoleKey.W:
                    --nowSelIndex;
                    if(nowSelIndex < 0)
                    {
                        nowSelIndex = 0;
                    }
                    break;
                    case ConsoleKey.S:
                    ++nowSelIndex;  
                    if(nowSelIndex >1)
                    {
                        nowSelIndex = 1;
                    }
                    break;
                  case ConsoleKey.J:
                     EnterJDoSomething ();
                    break;
            }

        }
    }
}
